package com.emergency.embackend.controller;

import com.emergency.embackend.common.R;
import com.emergency.embackend.service.*;
import com.emergency.embackend.vo.HistoryDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;
    @Autowired
    private WikiArticleService wikiArticleService;
    @Autowired
    private WikiVideoService wikiVideoService;
    @Autowired
    private QuizHistoryService quizHistoryService;
    @Autowired
    private ShareDataService shareDataService;

    @GetMapping("getDataInWeek")
    public R getDataInWeek() {
        return R.ok().put("data", historyService.getDataInWeek());
    }

    @GetMapping("getDataInMonth")
    public R getDataInMonth() {
        return R.ok().put("data", historyService.getDataInMonth());
    }

    @GetMapping("getHistory")
    public R getHistory(@RequestParam("userId") Long userId) {
        HistoryDetailVO historyDetailVO = new HistoryDetailVO();
        historyDetailVO.setArticleVOList(wikiArticleService.getHistory(userId));
        historyDetailVO.setVideoList(wikiVideoService.getHistory(userId));
        historyDetailVO.setQuizSuitVOList(quizHistoryService.getHistory(userId));
        historyDetailVO.setShareVOList(shareDataService.getHistory(userId));
        return R.ok().put("data",historyDetailVO);
    }
}
